<template>
  <my-table listPath="page" savePath="save" deletePath="delete" :table="table" :rules="rules" dialogTitle="对话框" :pageSize="[3,5,10,20,35,50]" :dialogForm="form">
    <template v-slot:dialogSlot>
      <el-form-item label="学号" prop="stuNo">
          <el-input v-model="form.stuNo" clearable></el-input>
      </el-form-item>
      <el-form-item label="姓名" prop="name">
          <el-input v-model="form.name" clearable></el-input>
      </el-form-item>
      <el-form-item label="性别" prop="sex">
          <el-input v-model="form.sex" clearable></el-input>
      </el-form-item>
    </template>

    <template v-slot:mybutton>
      <el-button type="primary" size="small" icon="el-icon-edit" circle @click="logout()">注销</el-button>
    </template>
  </my-table>
</template>

<script>
  import myTable from '../components/myTable.vue';
  export default{
    components:{myTable},
    data() {
      return {
        form:{
          stuNo:'',
          name:'',
          sex:'',
        },
        table:[
          {
            title:'学号',
            field:'stuNo'
          },
          {
            title:'姓名',
            field:'name'
          },
          {
            title:'性别',
            field:'sex'
          }
        ],
        rules:{
           stuNo: [{ required: true, message: '请输入学号', trigger: 'blur' }],
           name: [{ required: true, message: '请输入姓名', trigger: 'blur' }],
            sex: [{ required: true, message: '请输入性别', trigger: 'blur' }],
        },
      }
    },
    methods:{
      logout(){
        this.$ajax.post('logout',{}).then(res=>{
          var result = res.data;
          if(result.success){
            window.sessionStorage.removeItem("token");
            window.sessionStorage.removeItem("name");
            this.$router.replace('/');
          }
        })
      }
    }
  }
</script>

<style>
</style>
